package tag28_19_08.serial;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;


public class Ser01_SaveLoadArray {

	public static void main(String[] args) throws Exception {
		
		int[] arr1 = { 1, 2, 3, 4, 6 };
		
		//1. in einer Datei speichern
		ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream("array") );
		oos.writeObject(arr1);
		oos.close();

		//2. aus einer Datei laden
		ObjectInputStream ois = new ObjectInputStream( new FileInputStream("array") );
		int[] arr2 = (int[])ois.readObject();
		ois.close();
		
		System.out.println( Arrays.toString(arr1) );
		System.out.println( Arrays.toString(arr2) );
		
		System.out.println(arr1 == arr2);
		System.out.println(arr1.equals(arr2));
		
	} 

}
